package com.xiguaji.tiktok.v1.tiktok.music.dto;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.io.Serializable;

@Data
public class DistributionRecord implements Serializable {
    private String description;
    private double percent;


    public static void main(String[] args) throws JsonProcessingException {
        //String ss = "[{\"description\":\"Arts \",\"percent\":44.1},{\"description\":\"Love & Dating\",\"percent\":15.3},{\"description\":\"Others\",\"percent\":14.8},{\"description\":\"Comedy\",\"percent\":4.6},{\"description\":\"Games\",\"percent\":4.6},{\"description\":\"Auto\",\"percent\":3.6},{\"description\":\"Animation\",\"percent\":2.8},{\"description\":\"Music\",\"percent\":2.8},{\"description\":\"Emotion & Drama\",\"percent\":2.5}]";
        String ss = "{\"description\":\"Arts \",\"percent\":44.1}";


        ObjectMapper mapper = new ObjectMapper();
        DistributionRecord list = mapper.readValue(ss, new TypeReference<>(){});

        System.out.println(list);

        /*list.forEach(x ->{
            System.out.println(x);
        });*/
    }
}
